ababc2
@@ -114,16 +114,23 @@
public class BeanExpirationScheduler<I, T> implements Scheduler<I> {
         @Override
         public void run() {
             InfinispanEjbLogger.ROOT_LOGGER.tracef("Expiring stateful session bean %s", this.id);
+            boolean complete = false;
             try (Batch batch = BeanExpirationScheduler.this.batcher.createBatch()) {
                 try {
                     BeanExpirationScheduler.this.remover.remove(this.id, BeanExpirationScheduler.this.expiration.getRemoveListener());
+                    complete = true;
                 } catch (Throwable e) {
                     InfinispanEjbLogger.ROOT_LOGGER.failedToExpireBean(e, this.id);
                     batch.discard();
                 }
             } finally {
                 synchronized (this) {
-                    BeanExpirationScheduler.this.expirationFutures.remove(this.id);
+                    if (complete) {
+                        BeanExpirationScheduler.this.expirationFutures.remove(this.id);
+                    } else {
+                        // If bean failed to expire, likely due to a lock timeout, just reschedule it
+                        BeanExpirationScheduler.this.schedule(this.id);
+                    }
                 }
             }
         }
